<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link rel="stylesheet" type="text/css" href="static/css/default.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/layout.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/general.css"/>
        <link rel="stylesheet" type="text/css" href="static/css/jquery.theme.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.core.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.datepicker.css" media="all" />

        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.button.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.resizable.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.dialog.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.tooltip.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.tooltip.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.menu.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.override.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/list_favorite.css" media="all" />

        <link rel="stylesheet" type="text/css" href="static/css/user-own.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/profile.css" media="all" />
        <script type='text/javascript' src='static/js/jquery.min.js'></script>
        <script type='text/javascript' src='static/js/menu.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.core.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.widget.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.datepicker.js'></script>

        <script type='text/javascript' src='static/js/jquery.ui.button.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.draggable.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.mouse.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.position.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.resizable.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.dialog.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.tooltip.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.menu.js'></script>

        <script type='text/javascript' src='static/js/general.js'></script>
        <script type='text/javascript' src='static/js/profile.js'></script>
        <script type='text/javascript'>
			$(document).ready(function(){
				$('.add_favorite').click(function(event){
					event.preventDefault();
					$id = $(this).attr('id').replace('favorite_','');
					 if($(this).hasClass('finish')){
	                        return;
	                  }
					var $option = {
								url: 'index.php?c=search&m=addtofavorite',
								type: 'POST',
								data:'favorite[id]=' + $id + '&favorite[isAjax]=' + 1,
								dataType:'text',
								success: function($reponse){
									$response = eval('(' + $reponse + ')');
									if($response.result == 1)
									{
										$('#favorite_' + $response.id).removeClass('add_favorite').removeClass('remove').addClass('finish');
										$('#favorite_' + $response.id).html('Added');
									}
									else
									{
										alert("Can't add memmber to favorite.");
									}
								},
								error: function(){
									}
							};
					$.ajax($option);
				});
			});
		</script>
    </head>
    <body>
        <div class="body">
            <div class="header">
                <div class="float-left text-left login">
                    <span>Welcome lampart.com.</span>
                   </span><a id="signin" class="sign-in" href="index.php?c=logout">Sign out</a>
                </div>
            </div>
            <div class="search">
                <div class="social-connect"></div>
                <div class="logo">
                    <a href="#" title="">Lampart.com</a>
                </div>
                <div class="search-control">
                    <form action="index.php?c=search" method="get" id="search_control">
                        <div class="search-category">
                            <div id="search_title" class="search-title">
                                <span id="search_category_title" style="font-size: 10px;"><?php echo $this->_get['search']['sex'] == 0 ? 'All': ($this->_get['search']['sex'] == 1 ? 'Male' : 'Female'); ?>  </span>
                                <img src="images/arrow_down.png" />
                            </div>
                            <ul id="search_menu" class="search-menu">
                                <li id="0" class="menu-option">All</li>
                                <li id="1" class="menu-option">Male</li>
                                <li id="2" class="menu-option">Female</li>
                            </ul>
                        </div>
                        <input type="hidden" id="search_controller" value="search" name="c" />
                        <input type="hidden" id="search_sex" value="<?php echo !empty($this->_get['search']['sex']) ? $this->_get['search']['sex'] : ''; ?>" name="search[sex]" />
                        <input type="text" name="search[name]" value="<?php echo !empty($this->_get['search']['name']) ? $this->_get['search']['name'] : ''; ?>" size="15" />
                        <input type="submit" id="search" name="search[search]" value="Search" />
                    </form>
                </div>
            </div>
            <div class="content">
                <div class="left">
                    <div class='header'>My profile</div>
                    <div class="main">
                        <div class="image">
                            <img  width='150px' height='150px' src="<?php echo !empty($this->userLog->picture) ? 'img/' . $this->userLog->picture : 'img/0.gif'; ?>"/>
                        </div>
                        <table>
                            <tr><td class="profile_head">Username:</td><td class="profile_detail"><?php echo $this->userLog->username; ?></td></tr>
                            <tr><td class="profile_head">Name:</td><td class="profile_detail"><?php echo $this->userLog->name; ?></td></tr>
                            <tr><td class="profile_head">Sex:</td><td class="profile_detail"><?php echo $this->userLog->sex == 1 ? 'Male' : 'Female'; ?></td></tr>
                            <tr><td class="profile_head">Address:</td><td class="profile_detail"><?php echo $this->userLog->address; ?></td></tr>
                            <tr><td class="profile_head">Birthday:</td><td class="profile_detail"><?php echo date('d-m-Y', $this->userLog->birthday); ?></td></tr>
                        </table>
                    </div>
                    <div class="control">
                        <a href="index.php">List favorite</a><br />
                        <a href="index.php?c=profile">Update profile</a><br />
                         <a href="index.php?c=profile&m=addavatar">Update avatar</a>
                    </div>
                    <div></div>
                </div>
                <div class="main-content">
                    <div class="profile">
                        <h2><span class="header-page">List result</span></h2>
                        <br />
                        <table>
                        <?php if(!empty($this->users)): ?>
                        <?php foreach ($this->users as $object): ?>
                            <tr><td class="image"><img src="img/<?php echo !empty($object->picture) ?  $object->picture : '0.gif'; ?>" width="50px" height="50px" /></td><td class="name"><?php echo $object->name. '<br /><span class=\'birthday\'>' .date('d-m-Y', $object->birthday) . '</span>'; ?></td><td><a class='remove add_favorite' id="favorite_<?php echo $object->id; ?>" href="#">Add to favorite</a></td></tr>
                         <?php endforeach; ?>
                         <?php else: ?>
                         	<tr><td colspan='2'>No result.</td></tr>
                         <?php endif;?>
                        </table>
                    </div>

                </div>
                <div class="right">

                </div>
            </div>
            <div class="clear-fix"></div>
            <div class="footer text-center">
                <a href="#">About</a><span class="separator">|</span>
                <a href="#">Privacy</a><span class="separator">|</span>
                <a href="#">Terms</a><span class="separator">|</span>
                <a href="#">Feedback</a><span class="separator">|</span>
                <a href="#">Copyright</a>
                <br />
            </div>
        </div>
    </body>
</html>